<script>
function fn_nuevo(){
			/*$("#zonaContenedor").load("/gourmet-express/trunk/src/views/mrp/produccion/recetas/nuevo.php?nuevo=nuevo", function(){
					$.blockUI({
						message: $('#div_oculto'),
						css:{
						top: '10%'
					}
				}); 
			});*/
			
			$("#zonaContenedor").load("/gourmet-express/trunk/src/views/mrp/produccion/recetas/nuevo.php?nuevo=nuevo", function(){
			
			});
		}; 

	function fn_guardar(){
	      		var guardar = confirm("Desea guardar los datos?")
             if ( guardar ) {
				var str=$("#form_nuevo").serialize();
				$.ajax({
					url:'/gourmet-express/trunk/src/views/mrp/produccion/recetas/nuevo_save.php?nuevo=nuevo',
					data:str,
					type:'get',
					success:function (data){
						      listarRecetasProduccion();
							}
					   });
             }
    };
		
 function fn_editar(recetaId){			
			
		   $("#zonaContenedor").load("/gourmet-express/trunk/src/views/mrp/produccion/recetas/editar.php?txtRecetaId="+recetaId, function(){
		   	
		   });
 }
				
 function fn_actualizar(){
	var actualizar = confirm("Desea actualizar los datos?")
	if ( actualizar ) {
	var str=$("#form_editar").serialize();
	$.ajax({
		url:'/gourmet-express/trunk/src/views/mrp/produccion/recetas/editar_save.php',
		data:str,
		type:'get',
		success:function (data){
			    listarRecetasProduccion();
				}
		   });
	}
 };	
	      	
 function fn_detalle(recetaId)
 {
    $("#zonaContenedor").load("/gourmet-express/trunk/src/views/mrp/produccion/recetas/detalle.php?txtRecetaId="+recetaId, function(){
		   	
		   });
		   /*
				$("#div_oculto").load("/gourmet-express/trunk/src/views/mrp/produccion/recetas/detalle.php?txtRecetaId="+recetaId, function(){
					$.blockUI({
						message: $('#div_oculto'),
						css:{
							top: '20%'
						}
					}); 
				});*/
  };
			
 function fn_eliminar(pro_eli,tr_id){
      	/*
			var eliminar = confirm("�De verdad desea eliminar el usaurio: "+pro_eli+"?")
			if ( eliminar ) {
				var td_id=tr_id;
				$('#'+ tr_id).append('<td id="'+ td_id +'" bgcolor="white">Procesando..</td>')
				var str='eliminar=eliminar&txtCodigo='+pro_eli;
				$.ajax({
					url:'/gourmet-express/trunk/src/views/mrp/produccion/recetas/eliminar.php',
					data:str,
					type:'get',
					success:function (data){
						$('#'+tr_id).remove();
						fn_buscar();
					}
				});
      };*/
  };
		
 function fn_cerrar(){
	        $.unblockUI({ 
		    onUnblock: function(){
			$("#div_oculto").html("");
		     }
	       }); 
         };
  /*       
  function fn_buscar(){
     	$("#div_listar").html('<img src="/gourmet-express/trunk/imgs/iconsindicator.gif" >');
		  var str=$("#frm_buscaReceta").serialize();
		  $.ajax({
			url:'/gourmet-express/trunk/src/views/mrp/produccion/recetas/contenedor.php',
			data:str,
			type:'get',
			success:function (data){					  
					  $("#div_listar").html(data);
					}
			   });
      };
   */
  
</script>
<body>
<div id="module" style="width:900px;"><?php
    if (!$modoBusqueda){
      $contextMenu[0]["link"]      = "javascript:fn_nuevo()";
      $contextMenu[0]["linkIcon"]  = "application_add.png";
      $contextMenu[0]["linkTitle"] = "Nueva Receta";
    }?>
    <?php include $_SERVER['DOCUMENT_ROOT'].'/gourmet-express/trunk/src/views/header.inc'; ?>
	<h3>:: Lista de Recetas </h3>
    <div>

		<form name="frm_buscaReceta" id="frm_buscaReceta">    
		    Receta Id : <input type="text" value="" size="15" name="txtRecetaId" id='txtRecetaId'>
		    Descripcion : <input type="text" value="" size="25" name="txtDescripcion" id='txtDescripcion'>  
		    <input type="submit" value="aceptar" name="Buscar"> 
		</form>       
		
		<table id="flex1" style="display:none"></table>
		<script type="text/javascript">
		$("#flex1").flexigrid({
			url: '/gourmet-express/trunk/src/views/mrp/produccion/recetas/contenedor.php',
			dataType: 'json',
			colModel : [
				{display: 'Receta Id', name : 'receta_Id', width : 60, sortable : true, align: 'center'},
				{display: 'Producto', name : 'producto', width : 60, sortable : true, align: 'left'},
				{display: 'Descripcion', name : 'descripcion', width : 200, sortable : true, align: 'left'},
				{display: 'Detalles', name : 'detalles', width : 200, sortable : true, align: 'left', hide: false},
				{display: 'Tipo Producto', name : 'tipoProduc', width : 55, sortable : true, align: 'right'},
				{display: 'Cant Producto', name : 'cantProdc', width : 55, sortable : true, align: 'right'},
				{display: 'UoM Producto', name : 'uomProdc', width : 55, sortable : true, align: 'right'},
				{display: '&nbsp;', name : 'opciones', width : 80, sortable : true, align: 'right'}
				],
			searchitems : [
				{display: 'Receta Id', name : 'receta_Id'},
				{display: 'Producto', name : 'producto', isdefault: true}
				],
			sortname: "receta_Id",
			sortorder: "asc",
			usepager: true,
			title: 'Recetas',
			useRp: true,
			rp: 15,
			showTableToggleBtn: true,
			width: 895,
			onSubmit: addFormData,
			height: 300
		});   
		
		
		//This function adds paramaters to the post of flexigrid. You can add a verification as well by return to false if you don't want flexigrid to submit			
		function addFormData(){
			//passing a form object to serializeArray will get the valid data from all the objects, but, if the you pass a non-form object, you have to specify the input elements that the data will come from
			var dt = $('#frm_buscaReceta').serializeArray();
			$("#flex1").flexOptions({params: dt});
			return true;
		}
			
		$('#frm_buscaReceta').submit(function (){
			$('#flex1').flexOptions({newp: 1}).flexReload();
			return false;
		});
		
		</script>
	</div>
	<div id="div_listar" align="center"></div>
	<div id="div_oculto" style="display: none;"></div>
</body>
<script>
//fn_buscar();
</script>